package conference.model;

import conference.TCPCommands;
import conference.controller.ServerSideTCP;

/**
*
* A representation of a Client. 
*
* It contains nickname, ip address.
* @author Samsjo-8
*/
public class Client {
	
	private String nick;
	String ipAddr;
	
	public Client(String ipAddr){
		this.ipAddr = ipAddr;
	}
	public Client(String ipAddr, String nick){
		this.ipAddr = ipAddr;
		this.nick = nick;
	}
	
	public String getipAddr(){
		return ipAddr;
	}
	
	public String getNick(){
		return nick;
	}
	
	public String setNick(String nickName){
		return this.nick=nickName;
	}
	
	/**
	 * @return true if the client is equal to the object (has the same IP address)
	 */
	public boolean equals(Object o){
		try{
			Client c = (Client) o;
			if(c.getipAddr().equals(this.getipAddr())&&this.nick.equals(c.nick))
				return true; else return false;
		} catch (Exception e){
			return false;
		}
	}
	
  /**
  * this method converts the client to a string representation used with tcp commands/messages.
  * 
  * @return a string representation of the class
  */
	public String toTransferString(){ //TODO: finish
		return ipAddr+TCPCommands.separator_withinEntry+nick;
	}
	
	
	
} 
